'''
Created on FEV 28, 2014

@author: rgrunitzki
'''

class Vehicle(object):
    
    def __init__(self, veh_id, origin, destination, mdp, current_time):
        self._id = veh_id
        self._origin = origin
        self._destination = destination
        self._current_edge = origin
        self._travel_time_on_link = 0
        self._current_time = current_time
        self._depart_time = 0
        self._travel_time = 0
        self.mdp = mdp
        self.route = []
        self.route.append(origin)
        self.removed = False
        '''
        initializes the driver's class
        
        :param driver_id: driver identificator
        :type driver_id: string
        '''
      
    def reset(self):
        self._current_edge = self._origin
        self._current_time = 0
        self._travel_time_on_link = 0
        self._depart_time = 0
        self._travel_time = 0
        self.route = []
        self.route.append(self._origin)
        self.removed = False

    def get_destination(self):
        return self._destination

    def get_id(self):
        return self._id

    
    def is_destination(self):
        if self._current_edge == self._destination:
            return True
        else:
            return False

    def get_current_edge(self):
        return self._current_edge


    def get_travel_time_on_link(self):
        return self._travel_time_on_link


    def set_current_edge(self, value):
        self._current_edge = value


    def set_travel_time_on_link(self, current_time):
        self.update_travel_time(current_time)
        #if self._current_edge != self._origin:
        self._travel_time_on_link = current_time - self._current_time
        self._current_time = current_time
    
    def set_travel_time(self, current_time):
        self._travel_time = current_time
    
    def update_travel_time(self, current_time):
        self._travel_time = current_time - self._depart_time
        
    def get_travel_time(self):
        return self._travel_time
    
    def set_depart_time(self, current_time):
        self._depart_time = current_time
    
    def get_number_of_actions(self):
        return len(self.route)